<?php
namespace Classes\db;

use PDO;

class DBConnection
{
	private static $instance;
	private $connection;

	private function __construct()
	{
		$connectionString = 'mysql:host=localhost;dbname=happy_footballers;charset=utf8';
		$this->connection = new \PDO($connectionString , "root", "");
		$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	}

	private function __clone(){}

	public static function getInstance()
	{
		if(empty(self::$instance))
		{
			self::$instance = new DBConnection();
		}

		return self::$instance;
	}

	public function getConnection()
	{
		return $this->connection;
	}

	public static function getDBConnection()
	{
		return self::getInstance()->getConnection();
	}

}